#!/bin/bash
source "${LMD_BASE_INSTALL_SCRIPT_DIR}/global/sys_check.sh"
echo "lmdprogress:10"

function check_app_path_win {
    OLLAMA_ACTUAL_INSTALL_PATHS=$(where.exe "ollama app.exe" 2>/dev/null)
    if [ -z "$OLLAMA_ACTUAL_INSTALL_PATHS" ]; then
        echo "The installed Ollama could not be found."
    else
        echo "$OLLAMA_ACTUAL_INSTALL_PATHS" | while read -r path; do
            echo "found path: $path"
        done
        FIRST_PATH=$(echo "$OLLAMA_ACTUAL_INSTALL_PATHS" | head -n 1)
        echo "The first path: "$FIRST_PATH
        # explorer.exe "$FIRST_PATH"
        INSTALL_PATH=$(dirname "$FIRST_PATH")
    fi
    echo $INSTALL_PATH
}

function remove_app_win {
  echo "Find install path."
  check_app_path_win
  echo "call $INSTALL_PATH\\unins000.exe"
  "$INSTALL_PATH\\unins000.exe"
}

if [ -f /System/Library/CoreServices/SystemVersion.plist ]; then
    echo "macOS"
    echo "this script is for windows."
    echo "lmdprogress:100"
    exit 1
elif current_os_is_windows; then
    echo "Windows"
    remove_app_win
    echo "lmdprogress:100"
fi
